﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using GameSPK.Model;
using System.IO;
using System.Xml.Linq;
namespace GameSPK.DAO
{
    class TungNguoiChoiXMLDAO
    {
        public static Model.LabelLayout getButtonBack()
        {
            string fileXML = Helper.folderLayout + "/TungNguoiChoiLayout.xml";
            LabelLayout video = new LabelLayout();
            if (File.Exists(fileXML))
            {
                XElement layout = XElement.Load(fileXML);
                var home = (from c in layout.Elements()
                            where c.Name == "ButtonBack"
                            select c).Single();
                video.Left = double.Parse(home.Attribute("Left").Value);
                video.Top = double.Parse(home.Attribute("Top").Value);
                video.Width = double.Parse(home.Attribute("Width").Value);
                video.Height = double.Parse(home.Attribute("Height").Value);
                return video;
            }
            return null;
        }
        public static Model.LabelLayout getLabel(String name)
        {
            string fileXML = Helper.folderLayout + "/TungNguoiChoiLayout.xml";
            LabelLayout video = new LabelLayout();
            if (File.Exists(fileXML))
            {
                XElement layout = XElement.Load(fileXML);
                var home = (from c in layout.Elements()
                            where c.Name == name
                            select c).Single();
                video.Left = double.Parse(home.Attribute("Left").Value);
                video.Top = double.Parse(home.Attribute("Top").Value);
                video.Width = double.Parse(home.Attribute("Width").Value);
                video.Height = double.Parse(home.Attribute("Height").Value);
                video.FontSize = double.Parse(home.Attribute("FontSize").Value);
                video.sBackground = home.Attribute("BackGround").Value;
                video.sForeground = home.Attribute("Foreground").Value;
                return video;
            }
            return null;
        }
    }
}
